package com.sia.springcloud.process.influxDB;

import com.sia.springcloud.process.influxDB.InfluxDBConfig;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.BatchPoints;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @ClassName InfluxDbTool
 * @Description TODO
 * @Author sgw
 * @Date 2022-4-13 16:09
 * @Version 1.0
 **/
@Slf4j
@Component
public class InfluxDbTool {

    @Autowired
    private InfluxDBConfig influxDBConfig;

    @Async
    public synchronized void saveInfluxDb(BatchPoints batchPoints, String database) throws Exception{

        influxDBConfig.batchInsert(batchPoints,database);//按设备批量保存
    }
}
